<?php
require_once 'application/library/db/gcBasicDao.php';
require_once 'application/constant/dbConstant.php';
class dao_T_EC_M_FORMULADao extends gcBasicDao {
    protected $_table = "T_EC_M_FORMULA";

    public function pbGetFormulaInfo($strFormulaNo) {
        $sql = "select * from T_EC_M_FORMULA as A left join T_EC_M_GOODS as B
                on A.GOODS_NO = B.GOODS_NO  where FORMULA_NO = :FormulaNo ";
        $parameter = array("FormulaNo" => $strFormulaNo);
        $arrFormulaInfo = $this->select($sql, $parameter, dbReturnType::ROW);
        return $arrFormulaInfo;
    }

    public function pbInsertFormula($strGoodsNo, $strFormulaName) {
        $sql = "insert into T_EC_M_FORMULA (FORMULA_NAME,
                                            GOODS_NO )
                                   values(:FormulaName,
                                          :GoodsNo) ";
        $parameter = array("GoodsNo"     => $strGoodsNo,
                           "FormulaName" => $strFormulaName);
        $strFormulaNo = $this->insert($sql, $parameter);
        return $strFormulaNo;
    }

    public function pbUpdateFomula($strFormulaNo, $strFormulaName) {
        $sql = "update  T_EC_M_FORMULA set FORMULA_NAME = :FormulaName
                                   where FORMULA_NO = :FormulaNo ";
        $parameter = array("FormulaNo"     => $strFormulaNo,
                           "FormulaName" => $strFormulaName);
        $strUpdateRe = $this->update($sql, $parameter);
        return $strUpdateRe;
    }

    public function pbGetFormulaCount() {
        $sql = " select count(*) from T_EC_M_FORMULA ";
        $parameter = array();
        $intCount = $this->select($sql, $parameter, dbReturnType::ONE);
        return $intCount;
    }

    public function pbGetFormula() {
        $sql = " select * from T_EC_M_FORMULA ";
        $parameter = array();
        $arrFormula = $this->select($sql, $parameter, dbReturnType::ALL);
        return $arrFormula;
    }

    public function pbGetSearchCount($strFormulaName) {
        $sql = " select count(*) from T_EC_M_FORMULA where FORMULA_NAME LIKE CONCAT('%' , :FormulaName , '%') ";
        $parameter = array("FormulaName" => $strFormulaName);
        $intCount = $this->select($sql, $parameter, dbReturnType::ONE);
        return $intCount;
    }

    public function pbSearchFormula($strFormulaName) {
        $sql = " select * from T_EC_M_FORMULA where FORMULA_NAME LIKE CONCAT('%' , :FormulaName , '%') ";
        $parameter = array("FormulaName" => $strFormulaName);
        $arrFormula = $this->select($sql, $parameter, dbReturnType::ALL);
        return $arrFormula;
    }
}
